﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk.Metadata;
using System.ComponentModel;

namespace CRMCustom.Parser
{
    public class ExtendedAttributeMetadata : CRMTransaction
    {
        public ExtendedAttributeMetadata(AttributeMetadata attribute)
        {
            this.Attribute = attribute;
            this.IncludeInTransaction = true;
        }

        [Browsable(false)]
        public AttributeMetadata Attribute
        { get; set; }

        [Browsable(false)]
        public string OwnerEntity { get; set; }

        #region Basic Browsable Attributes
        [Browsable(true), Category("Basic")]
        public string SchemaName
        {
            get
            {
                return Attribute.SchemaName;
            }
            set
            {
                Attribute.SchemaName = value;
            }
        }

        [Browsable(true), Category("Basic")]
        public string Description
        {
            get
            {
                return Attribute.Description.LocalizedLabels[0].Label;
            }
            set
            {
                Attribute.Description.LocalizedLabels[0].Label = value;
            }
        }

        [Browsable(true), Description("Display name of attribute"), Category("Basic")]
        public string DisplayName
        {
            get
            {
                return Attribute.DisplayName.LocalizedLabels[0].Label;
            }
            set
            {
                Attribute.DisplayName.LocalizedLabels[0].Label = value;
            }
        }

        [Browsable(true), Category("Basic")]
        public AttributeRequiredLevel RequiredLevel
        {
            get
            {
                return Attribute.RequiredLevel.Value;
            }
            set
            {
                Attribute.RequiredLevel.Value = value;
            }
        }
        #endregion Basic Browsable Attributes
    }
}
